/*
Copyright (c) 2007, Arturo José Guédez Romero

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
    * Neither the name of Cultusoft nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.cultusoft.groovin.configuration;

import com.cultusoft.groovin.plugins.build.Project
import com.cultusoft.groovin.plugins.project.ProjectFactory;
import com.cultusoft.groovin.script.command.localized.WorkoutLoggerWebAppTester
import com.cultusoft.groovin.script.command.localized.WorkoutLoggerCoreTester

class ProjectConfiguration {

    public Collection<Project> createProjects() {

        Project XSTREAM    = ProjectFactory.createLibraryProject(group:"xstream", id:"xstream", version:"1.2.1")
        Project LOG4J       = ProjectFactory.createLibraryProject(group:"log4j", id:"log4j", version:"1.2.11")
        Project JUNIT       = ProjectFactory.createLibraryProject(group:"junit", id:"junit", version:"4.1") 

        Project COMMONS_LANG = ProjectFactory.createLibraryProject(group:"commons-lang", id:"commons-lang", version:"2.2")
        Project COMMONS_COLLECTIONS = ProjectFactory.createLibraryProject(group:"commons-collections", id:"commons-collections", version:"3.2")
        Project COMMONS_LOGGING = ProjectFactory.createLibraryProject(group:"commons-logging", id:"commons-logging", version:"1.1.1")
        Project COMMONS_HTTPCLIENT = ProjectFactory.createLibraryProject(group:"commons-httpclient", id:"commons-httpclient", version:"3.1")
        Project COMMONS_CODEC = ProjectFactory.createLibraryProject(group:"commons-codec", id:"commons-codec", version:"1.3")
        Project CAJO        = ProjectFactory.createLibraryProject(group:"cajo", id:"cajo", version:"1.0")
        Project HIBERNATE   = ProjectFactory.createLibraryProject(group:"hibernate", id:"hibernate", version:"3.1rc2")
        Project STRIPES     = ProjectFactory.createLibraryProject(group:"net/sourceforge/stripes", id:"stripes", version:"1.4.1")
        Project XERCES      = ProjectFactory.createLibraryProject(group:"xerces", id:"xerces", version:"2.4.0")
        Project DOM4J       = ProjectFactory.createLibraryProject(group:"dom4j", id:"dom4j", version:"1.6.1")
        Project ASM         = ProjectFactory.createLibraryProject(group:"asm", id:"asm", version:"1.5.3")
        Project FIT_LIBRARY  = ProjectFactory.createLibraryProject(group:"org/fitnesse", id:"fitlibrary", version:"20060719")
        Project FITNESSE =    ProjectFactory.createLibraryProject(group:"org/fitnesse", id:"fitnesse", version:"20060719")

        Project SELENIUM_JAVA_CLIENT_DRIVER = ProjectFactory.createLibraryProject(group:"org/openqa/selenium/client-drivers", id:"selenium-java-client-driver", version:"0.9.2")
        Project SELENIUM_JAVA_CLIENT_DRIVER_TESTS = ProjectFactory.createLibraryProject(group:"org/openqa/selenium/client-drivers", id:"selenium-java-client-driver", version:"0.9.2-tests")

        Project COS = ProjectFactory.createLibraryProject(group:"servlets/com", id:"cos", version:"05Nov2002")
        Project JUNIT_ADDONS = ProjectFactory.createLibraryProject(group:"junit-addons", id:"junit-addons", version:"1.4")
        Project MYSQL_CONNECTOR_JAVA = ProjectFactory.createLibraryProject(group:"mysql", id:"mysql-connector-java", version:"5.1.5")
        Project CGLIB = ProjectFactory.createLibraryProject(group:"cglib", id:"cglib", version:"2.1_3")
        Project JTA = ProjectFactory.createLibraryProject(group:"javax/transaction", id:"jta", version:"1.0")
        Project SERVLET_API = ProjectFactory.createLibraryProject(group:"tomcat", id:"servlet-api", version:"5.5.23")
        Project JSP_API = ProjectFactory.createLibraryProject(group:"tomcat", id:"jsp-api", version:"5.5.23")
        Project JSTL = ProjectFactory.createLibraryProject(group:"javax/servlet", id:"jstl", version:"1.0")
        Project STANDARD = ProjectFactory.createLibraryProject(group:"taglibs", id:"standard", version:"1.1.2")
        Project JWEBUNIT_CORE = ProjectFactory.createLibraryProject(group:"net/sourceforge/jwebunit", id:"jwebunit-core", version:"1.4-rc4")
        Project HTTP_UNIT = ProjectFactory.createLibraryProject(group:"httpunit", id:"httpunit", version:"1.6.2")

        Project WORKOUT_LOGGER_CONFIGURATION = ProjectFactory.createProject(dirName:"WorkoutLogger-Configuration")  

        Project WORKOUT_LOGGER_DOMAIN_MODEL = ProjectFactory.createProject(dirName:"WorkoutLogger-Domain-Model")
        Project WORKOUT_LOGGER_DOMAIN_MODEL_TEST = ProjectFactory.createTestProject(dirName:"WorkoutLogger-Domain-Model")

        Project WORKOUT_LOGGER_BUSINESS_LAYER = ProjectFactory.createProject(dirName:"WorkoutLogger-Business-Layer")

        Project WORKOUT_LOGGER_PERSISTENCE_LAYER = ProjectFactory.createProject(dirName:"WorkoutLogger-Persistence-Layer")
        Project WORKOUT_LOGGER_PERSISTENCE_LAYER_TEST = ProjectFactory.createTestProject(dirName:"WorkoutLogger-Persistence-Layer")

        Project WORKOUT_LOGGER_CORE = ProjectFactory.createProject(dirName:"WorkoutLogger-Core")
        Project WORKOUT_LOGGER_CORE_TEST = ProjectFactory.createTestProject(dirName:"WorkoutLogger-Core")

        Project WORKOUT_LOGGER_PERSISTENCE_HIBERNATE = ProjectFactory.createProject(dirName:"WorkoutLogger-Persistence-Hibernate")
        Project WORKOUT_LOGGER_PERSISTENCE_HIBERNATE_TEST = ProjectFactory.createTestProject(dirName:"WorkoutLogger-Persistence-Hibernate")

        Project WORKOUT_LOGGER = ProjectFactory.createProject(dirName:"WorkoutLogger")
        Project WORKOUT_LOGGER_TEST = ProjectFactory.createTestProject(dirName:"WorkoutLogger")
        Project WORKOUT_LOGGER_WAR = ProjectFactory.createWarProject(dirName:"WorkoutLogger")  

        Project DATA_PROVIDER = ProjectFactory.createProject(dirName:"DataProvider")
        Project DATA_PROVIDER_LAYER = ProjectFactory.createProject(dirName:"DataProvider-Layer")
        Project DATA_PROVIDER_WAR = ProjectFactory.createWarProject(dirName:"DataProvider")

        Project WORKOUT_LOGGER_PERSISTENCE_MEMORY = ProjectFactory.createProject(dirName:"WorkoutLogger-Persistence-Memory")

        Project WORKOUT_LOGGER_BLACK_BOX = ProjectFactory.createProject(dirName:"WorkoutLogger-BlackBox")





        WORKOUT_LOGGER_CONFIGURATION.setDependencies([XSTREAM] as Set)

        WORKOUT_LOGGER_DOMAIN_MODEL.setDependencies([COMMONS_LANG] as Set)

        WORKOUT_LOGGER_DOMAIN_MODEL_TEST.setDependencies([WORKOUT_LOGGER_DOMAIN_MODEL,
                JUNIT] as Set)

        WORKOUT_LOGGER_BUSINESS_LAYER.setDependencies( [WORKOUT_LOGGER_DOMAIN_MODEL, 
                WORKOUT_LOGGER_CONFIGURATION,
                LOG4J,
                COMMONS_LANG] as Set)


        WORKOUT_LOGGER_PERSISTENCE_LAYER.setDependencies([WORKOUT_LOGGER_DOMAIN_MODEL,
                WORKOUT_LOGGER_CONFIGURATION] as Set)

        WORKOUT_LOGGER_PERSISTENCE_LAYER_TEST.setDependencies([WORKOUT_LOGGER_PERSISTENCE_LAYER,
                JUNIT ] as Set)


        WORKOUT_LOGGER_CORE.setDependencies([WORKOUT_LOGGER_DOMAIN_MODEL,
                WORKOUT_LOGGER_BUSINESS_LAYER,
                WORKOUT_LOGGER_PERSISTENCE_LAYER,
                LOG4J] as Set)        

        WORKOUT_LOGGER_CORE.tester = new WorkoutLoggerCoreTester(project:WORKOUT_LOGGER_CORE)


        WORKOUT_LOGGER_CORE_TEST.setDependencies([WORKOUT_LOGGER_CORE,
                JUNIT] as Set)                                     

        WORKOUT_LOGGER_PERSISTENCE_HIBERNATE.setDependencies([WORKOUT_LOGGER_DOMAIN_MODEL,
                WORKOUT_LOGGER_PERSISTENCE_LAYER,
                CAJO,
                HIBERNATE,
                DOM4J,
                LOG4J,
                COMMONS_LANG] as Set)		

        WORKOUT_LOGGER_PERSISTENCE_HIBERNATE.DEFAULT_RESOURCES_DIRECTORY_LIST = ["src/resources"] as List                                                                  

        WORKOUT_LOGGER_PERSISTENCE_HIBERNATE_TEST.setDependencies([WORKOUT_LOGGER_PERSISTENCE_HIBERNATE,
                COMMONS_LOGGING,
                JUNIT] as Set) 

        WORKOUT_LOGGER.setDependencies([WORKOUT_LOGGER_DOMAIN_MODEL,
                WORKOUT_LOGGER_BUSINESS_LAYER,
                WORKOUT_LOGGER_PERSISTENCE_HIBERNATE,
                WORKOUT_LOGGER_CORE,
                DATA_PROVIDER_LAYER,
                LOG4J,
                STRIPES,
                SERVLET_API,
                //JSP_API,
                COMMONS_LANG] as Set)                                                                       

        WORKOUT_LOGGER.DEFAULT_RESOURCES_DIRECTORY_LIST = ["src/resources"] as List

        WORKOUT_LOGGER_TEST.setDependencies([WORKOUT_LOGGER,
                COMMONS_LOGGING,
                JUNIT] as Set)   



        WORKOUT_LOGGER_WAR.setDependencies([WORKOUT_LOGGER,
                COMMONS_LOGGING,
                DATA_PROVIDER
                ] as Set)     

        WORKOUT_LOGGER_WAR.tester = new WorkoutLoggerWebAppTester(project:WORKOUT_LOGGER_WAR)

        WORKOUT_LOGGER_WAR.DEFAULT_RESOURCES_DIRECTORY_LIST = ["src/resources", "etc/webapp/files"] as List

        DATA_PROVIDER_WAR.setDependencies([DATA_PROVIDER] as Set)


        DATA_PROVIDER.setDependencies([DATA_PROVIDER_LAYER,
                SERVLET_API,
                COMMONS_LANG,
                COMMONS_HTTPCLIENT,
                COMMONS_CODEC ] as Set)

        DATA_PROVIDER_LAYER.setDependencies([WORKOUT_LOGGER_CONFIGURATION,
                WORKOUT_LOGGER_DOMAIN_MODEL] as Set)


        WORKOUT_LOGGER_BLACK_BOX.setDependencies([WORKOUT_LOGGER,
                WORKOUT_LOGGER_BUSINESS_LAYER,
                WORKOUT_LOGGER_CORE,
                WORKOUT_LOGGER_DOMAIN_MODEL,
                WORKOUT_LOGGER_PERSISTENCE_HIBERNATE,
                WORKOUT_LOGGER_PERSISTENCE_MEMORY,
                FITNESSE,
                JUNIT,
                JWEBUNIT_CORE,
                HTTP_UNIT,
                STRIPES] as Set)

        WORKOUT_LOGGER_BLACK_BOX.DEFAULT_SRC_DIRECTORY_LIST = ["src/blackboxtest"] as List
        WORKOUT_LOGGER_BLACK_BOX.DEFAULT_RESOURCES_DIRECTORY_LIST = ["src/resources", "fitnesse/FitNesseRoot/WorkoutLogger"] as List



        WORKOUT_LOGGER_PERSISTENCE_MEMORY.setDependencies([WORKOUT_LOGGER_DOMAIN_MODEL,
                                                            WORKOUT_LOGGER_PERSISTENCE_LAYER] as Set)                                                      
        HIBERNATE.setDependencies([DOM4J,
                COMMONS_COLLECTIONS,
                MYSQL_CONNECTOR_JAVA,
                CGLIB,
                ASM,
                JTA,
                STANDARD] as Set)

        STRIPES.setDependencies([COS,
                JSTL] as Set)  

        JUNIT.setDependencies([JUNIT_ADDONS] as Set)

        FITNESSE.setDependencies([
                XERCES,
                FIT_LIBRARY,
                SELENIUM_JAVA_CLIENT_DRIVER,
                SELENIUM_JAVA_CLIENT_DRIVER_TESTS,
                ] as Set)
		

       return ProjectFactory.getProjects();
    }

}
